package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// GetOpenidService 获取OpenID服务
type GetOpenidService struct {
	*services.BaseService
}

// NewGetOpenidService 创建获取OpenID服务
func NewGetOpenidService(config *core.Config) *GetOpenidService {
	return &GetOpenidService{
		BaseService: services.NewBaseService(config),
	}
}

// GetOpenid 获取OpenID
func (s *GetOpenidService) GetOpenid(request *common.GetOpenidRequest) (*common.GetOpenidResponse, error) {
	response := common.NewGetOpenidResponse()
	err := s.Post(request, response, "/open/trans/getopenid")
	if err != nil {
		return nil, err
	}
	return response, nil
}
